package com.mall.mymall.dao.dto;

import lombok.Data;

import javax.validation.constraints.Pattern;
import java.util.Objects;

@Data
public class UserDto {
    // 用户名
    private String username;
    // 密码
    private String password;
    // 令牌
    private String Token;

    @Pattern(regexp = "^\\w+@\\w+\\.com+$", message = "邮箱格式不正确")
    private String email;

    @Pattern(regexp = "^1[3-9]\\d{8}$", message = "手机号格式不正确")
    private String phone;

    private Integer roleId;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserDto userDto = (UserDto) o;
        return Objects.equals(username, userDto.username) && Objects.equals(password, userDto.password) && Objects.equals(email, userDto.email) && Objects.equals(phone, userDto.phone) && Objects.equals(roleId, userDto.roleId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(username, password, email, phone, roleId);
    }

}
